<?php
html::printPath('userSpace.account-display-header', 'userSpace.account-display-desc');
$msg->printMessages();
?>

<div class="commandListFlow ui-helper-clearfix">
	<ul class="commandList">
	    <li class="editLi"><?php echo html::anchor('user/myAccount/edit', text::get('userSpace.account-edit')) ?></li>
	    <li class="editLi"><?php echo html::anchor('user/myAccount/changePassword', text::get('userSpace.changePassword')) ?></li>
	</ul>
	<ul class="commandList">
	    <li class="registrationsLi"><?php echo html::anchor('user/myRegistration/all', text::get('userSpace.menu-myRegistrations')) ?></li>
	</ul>
	<?php
	// Don't show managed persons to substituted users.
	// It could get quite confusing.
	if (! $this->getAuthOrSubstituteUser('manager_id')) {
		echo '<ul class="commandList">';
		echo '<li class="suCommand">' . html::anchor('user/managedPerson/listing', text::get('managedPerson-form-title')) . '</li>';
		echo '</ul>';
	}
echo '</div>';

$fullName = $account['first_name'] . ' ' . $account['other_names'] . ' ' . $account['last_name'] . ($account['title'] ? ', ' . $account['title'] : '');

$fb = new FormBuilder('person', $account);
$fb->displayOnly();
$fb->display('full_name')->value($fullName)->identifyingValue();
$fb->display('yoga_name');
$fb->text('login');
$fb->spacer();
$fb->radioButtons('gender', array('M','F'), 'person.gender-');
$fb->date('birth_date');
$fb->text('idcard_number');
$fb->spacer();
$fb->text('street');
$fb->text('city');
$fb->text('postal_code');
$fb->comboBox('country_code', $countryOptions);
$fb->spacer();
$fb->text('telephone');
$fb->text('email');
$fb->write();

$organizerList = $this->getAuthUser('organizerList');
$representativeList = $this->getAuthUser('representativeList');
if ($organizerList || $representativeList) {
    if ($organizerList) {
        echo '<h3>' . text::getEscaped('userSpace.youAreOrganizerOfTheseOrgs') . ':</h3>';
        echo '<ul>';
        foreach ($organizerList as $organization) {
            echo '<li>' . html::anchor('/auth/switchOrganization?id=' . $organization['id'], $organization['name']) . ' (' . $organization['country']['name'] . ')</li>';
        }
        echo '</ul>';
    }
    
    if ($representativeList) {
        echo '<h3>' . text::getEscaped('userSpace.youAreRepOfTheseOrgs') . ':</h3>';
        echo '<ul>';
        foreach ($representativeList as $organization) {
            echo '<li>' . html::anchor('/auth/switchOrganization?id=' . $organization['id'], $organization['name']) . '</li>';
        }
        echo '</ul>';
    }
}